<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Top menu for store
 *
 * @see Mage_Catalog_Block_Navigation
 */
?>
<?php
/**
 * $this->renderCategoriesMenuHtml() supports optional arguments:
 * int Level number for list item class to start from
 * string Extra class of outermost list items
 * string If specified wraps children list in div with this class
 */
?>
<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div style="padding-bottom:10px;">
<ul class="breadcrumbs">
	<li class="category48">
		<a title="Go to Home Page" href="<?php echo $this->getUrl()?>">Home</a>
	</li>
	<li> / </li>
		<li class="category3">
		<strong>All Categories</strong>
	</li>
</ul>
<div class="clear"></div>
</div>
<div class="nav-container">
	<?php
	    $_helper    = $this->helper('catalog/output');
		$_imgHtml   = '';

		$activeCategories = array();
		foreach ($this->getStoreCategories() as $child) {
            if ($child->getIsActive()) {
                $activeCategories[] = $child;
            }
        }
		
		$i=0;
		foreach ($activeCategories as $category) {
			if (Mage::helper('catalog/category_flat')->isEnabled()) {
				$children = (array)$category->getChildrenNodes();
				$childrenCount = count($children);
			} else {
				$children = $category->getChildren();
				$childrenCount = $children->count();
			}
			$hasChildren = ($children && $childrenCount);
			
			$activeChildren = array();
			foreach ($children as $child) {
				if ($child->getIsActive()) {
					$activeChildren[] = $child;
				}
			}
			$activeChildrenCount = count($activeChildren);
			$hasActiveChildren = ($activeChildrenCount > 0);

			if ($_imgUrl = $this->getThumbnailUrl($category)) {
				$_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($category->getName()).'" title="'.$this->htmlEscape($category->getName()).'" /></p>';
				$_imgHtml = $_helper->categoryAttribute($category, $_imgHtml, 'image');
			}
			
			$class='';
			if($i==0) {
				$class=' first';
			}
			echo '<div class="category-list'.$class.'">';
			echo $_imgHtml;
		  	echo '<ul class="nav">';			
			echo '<li><a href="'.$this->getCategoryUrl($category).'"><span>'.$this->escapeHtml($category->getName()).'</span></a></li>';			
			foreach ($activeChildren as $child) {
				echo '<li class="child"><a href="'.$this->getCategoryUrl($child).'"><span>'.$this->escapeHtml($child->getName()).'</span></a></li>';
			}
			echo '</ul>';
			echo '<div class="clear"></div>';
			echo '</div>';
			$i++;
		}
	?>
</div>
<?php endif ?>